import utils.ConnectionUtil;

import java.sql.*;

/**
 * @projectName: Chapter8
 * @package: PACKAGE_NAME
 * @className: main
 * @author: 翟
 * @date: 2025/3/31 2:54
 */

public class Test1 {
    public static void main(String[] args) {
        try {
            Connection conn = ConnectionUtil.getConnection();
            Statement statement = conn.createStatement();
            ResultSet resultSet = statement.executeQuery("select * from patient");
            while (resultSet.next()) {
                System.out.println(resultSet.getInt(1));
                System.out.println(resultSet.getString(2));
            }
            ConnectionUtil.closeALL(resultSet, statement, conn);

            System.out.println("-----------------------------");

            Connection conn1 = ConnectionUtil.getConnection();
            PreparedStatement preparedStatement = conn1.prepareStatement("select * from patient");
            ResultSet resultSet1 = preparedStatement.executeQuery();
            while (resultSet1.next()) {
                System.out.println(resultSet1.getInt(1));
                System.out.println(resultSet1.getString(2));
            }
            ConnectionUtil.closeALL(resultSet1, preparedStatement , conn1);
        } catch (SQLException e) {
            e.printStackTrace();
        }
    }
}
